'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')
const token = 'c90637e8b0ca451eac7754b19e9683f9';

module.exports = {
  dev: {
    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      '/loginApi': {
        // target: 'http://172.20.0.187:8100/api/coframe/api/users/login',
        target: 'http://127.0.0.1:8080/mz/api/login',
        changeOrigin: true,
        pathRewrite: {
          '^/loginApi': ''
        }
      },
      '/ccmsApi': {
        // target: 'http://172.20.0.187:8200/api/',
        target: 'http://127.0.0.1:8080/mz/api/',
        changeOrigin: true,
        bypass: function (req, res, proxyOptions) {
          req.headers["X-EOS-SourceSysKey"] = token;
          req.headers["sysCode"] = 'ZCXT';
          //   req.headers["sysCode"] = 'ZM_CS';
        },
        pathRewrite: {
          //'^/ccmsApi': 'http://172.20.0.186:9090/'
          '^/ccmsApi': ''
        }
      },
      '/imgApi': {
        target: 'http://172.20.0.177:9101/',
        changeOrigin: true,
        bypass: function (req, res, proxyOptions) {
          req.headers["X-EOS-SourceSysKey"] = token;
        },
        pathRewrite: {
          //'^/imgApi': 'http://172.20.0.177:9101/'
          '^/imgApi': ''
        }
      },
      '/baseApi': {
        //测试环境
        target: 'http://localhost:9004/smartleasing/',
        //生产环境
        //target: 'http://172.20.0.193:9004/smartleasing/',
        changeOrigin: true,
        pathRewrite: {
          '^/baseApi': ''
        }
      },
      '/base2Api': {
        //测试环境
        target: 'http://localhost:9091/',
        //生产环境
        //target: 'http://172.20.0.193:9091/',
        changeOrigin: true,
        pathRewrite: {
          '^/base2Api': ''
        }
      },
      '/yunDing':{
        target:'https://saas-openapi.dding.net/v2/access_token/',
        changeOrigin: true,
        pathRewrite: {
          '^/yunDing': ''
        }
      },
      '/queryYunDing':{
        target:'https://saas-openapi.dding.net/v2/get_device_uuid/',
        changeOrigin: true,
        pathRewrite: {
          '^/queryYunDing': ''
        }
      },
      '/luMi':{
        target:'https://aiot-oauth2.aqara.cn/authorize/code/',
        changeOrigin: true,
        pathRewrite: {
          '^/luMi': ''
        }
      },
      '/tokenLuMi':{
        target:'https://aiot-oauth2.aqara.cn/access_token/',
        changeOrigin: true,
        pathRewrite: {
          '^/tokenLuMi': ''
        }
      },
      '/queryLuMi':{
        target:'https://aiot-oauth2.aqara.cn/3rd/v1.0/open/device/query/',
        changeOrigin: true,
        pathRewrite: {
          '^/queryLuMi': ''
        }
      },
      '/weiYu':{
        target:'http://47.110.53.42:9999/v3/Authorizations/systoken/',
        changeOrigin: true,
        pathRewrite: {
          '^/weiYu': ''
        }
      },
      '/queryWeiYu':{
        target:'http://47.110.53.42:9999/v4/devices/detail/',
        changeOrigin: true,
        pathRewrite: {
          '^/queryWeiYu': ''
        }
      },
      //发票
      '/nnfpbox':{
        target:'https://sdk.nuonuo.com/open/v1/services',
        changeOrigin: true,
        pathRewrite: {
          '^/nnfpbox': ''
        }
      },
    },

    // Various Dev Server settings
    host: '0.0.0.0', // can be overwritten by process.env.HOST
    port: 8888, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-


    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    // devtool: 'cheap-module-eval-source-map',
    devtool: 'source-map',
    
    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

  build: {
    // Template for index.html
    // index: path.resolve(__dirname, '../dist/index.html'),
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',

    /**
     * Source Maps
     */

    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}
